import 'dart:math';

void main() {
  // var 声明变量
  var name = "John";
  var rand = new Random();
  // var age = rand.nextInt(5); // age is >= 0 and < 5
  name = "Alice";
  // 循环打印
  for (var i = 0; i < 5; i++) {
    print("$i: Hello $name, you are ${rand.nextInt(3)} years old.");
  }

  // const 声明常量
  const pi = 3.14159265358979323846;
  // pi = 2 ; // 会报错，常量不能被修改
  const url = "https://www.google.com";
  print("Pi is $pi and the URL is $url");

  final year = 2021;
  // year = 20211; // 会报错，常量不能被修改
  print("The year is $year");

  var a = 1;
  var b = 2;
  // const c = a + b; // 会报错，const声明的常量不能包含变量
  const c = 3;
  const d = 4;
  const e = c + d; // 常量可以包含常量
  final f = a + b; // final 声明的常量可以包含变量
  print("The sum of $a and $b is $d");
  print("The sum of $c and $d is $e");
  print("The sum of $a and $b is $f");
}
